package com.gmail.blackdog1987.carcare.network.request.builder;

import android.content.Context;

import com.gmail.blackdog1987.carcare.Constant;
import com.gmail.blackdog1987.carcare.network.request.RequestBuilder;
import com.gmail.blackdog1987.carcare.util.DeviceUtils;
import com.gmail.blackdog1987.carcare.util.LogUtil;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class RegRequestBuilder extends RequestBuilder {

	private static final String TAG = RegRequestBuilder.class.getSimpleName();
	private String username; // 性倾向
	private String pwd; // 特殊癖好

	@Override
	public RequestParams buildRquest() {
		RequestParams params = new RequestParams();
		params.put("username", username);
		params.put("pwd", pwd);
		return params;
	}

	@Override
	public void postJsonRequest(Context context,
			AsyncHttpResponseHandler handler) {

		RequestParams params = buildRquest();

		AsyncHttpClient client = new AsyncHttpClient();
		client.setTimeout(Constant.TIMEOUT);
		client.setUserAgent(DeviceUtils.OS.getName());

		client.post(Constant.Action.REG, params, handler);
		LogUtil.d(TAG, "post : " + params);
	}


	public RegRequestBuilder setUsername(String username) {
		this.username = username;
		return this;
	}

	public RegRequestBuilder setPwd(String pwd) {
		this.pwd = pwd;
		return this;
	}
}
